{include file='head'/}
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <blockquote class="layui-elem-quote" style="background: rgba(236,239,161,0.6)">
                <b>提示：</b> <br>
                <span style="color:#f00;">强制覆盖，会强制覆盖已有的控制器和方法，请谨慎勾选。</span><br>
                创建成功后请自行更新一下权限节点。<br>
                路径：系统管理->权限节点->（强制）更新节点。
            </blockquote>
            <input type="hidden" name="table" value="<?=htmlspecialchars($table)?>">
            <div class="layui-form-item">
                <label class="layui-form-label required">菜单名</label>
                <div class="layui-input-block">
                    <input type="text" name="title" value="" required lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">菜单图标</label>
                <div class="layui-input-block">
                    <input type="text" name="icon" id="iconPicker2" value="" lay-filter="iconPicker2">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">上级菜单</label>
                <div class="layui-inline">
                    <select name="pid" lay-verify="" lay-search>
                        {volist name='pid_list' id='vo'}
                        <option value="{$vo.id}">{$vo.title}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">控制器</label>
                <div class="layui-input-block">
                    <input type="text" name="controller" value="<?=$controller?>" class="layui-input" required
                           lay-verify="required">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">模型</label>
                <div class="layui-input-block">
                    <input type="text" name="model" value="<?=$model?>" class="layui-input" required
                           lay-verify="required">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">强制覆盖</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="overwrite" lay-skin="primary">
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="admin-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

{include file='footer'/}
<script>
  layui.use(['form', 'jquery', 'iconPicker', 'xmSelect'], function () {
    let form = layui.form;
    let $ = layui.jquery;
    let iconPicker = layui.iconPicker;

    iconPicker.render({
      elem: '#iconPicker2',
      type: 'fontClass',
      style: 'color: #5FB878;',
      placeholder: '',
      isSplit: true,
      search: true,
      page: false,
      limit: 16,
      click: function (data) {
        console.log(data);
      },
      success: function (d) {
        console.log(d);
      }
      , ready: function () {
      }
    });

    form.on('submit(admin-save)', function (data) {
      $.ajax({
        url: "{:__url('system/database/table_crud')}",
        data: JSON.stringify(data.field),
        dataType: 'json',
        contentType: 'application/json',
        type: 'post',
        success: function (res) {
          if (res.code === 200) {
            hui_msg(res.msg, 1, function () {
              window.location.reload();
            });
          } else {
            hui_msg(res.msg, 2);
          }
        }
      })
      return false;
    });
  })
</script>
<script>
</script>
</body>
</html>
